Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: EXC-1735: Move scheduling into the inner round #1757

Closed
wants to merge 3 commits into from

Conversation

berestovskyy
Copy link
Contributor

By moving the scheduling strategy into the inner round, we can adjust canister priorities within each round. This allows for greater flexibility and responsiveness to change canister priorities.

@github-actions github-actions bot added the feat label Sep 30, 2024
@berestovskyy berestovskyy force-pushed the andriy/exc-1735-shedule-inner-round branch 2 times, most recently from 0a2a8f3 to f0ea8a7 Compare September 30, 2024 20:22
By moving the scheduling strategy into the inner round,
we can adjust canister priorities within each round.
This allows for greater flexibility and responsiveness
to change canister priorities.
@berestovskyy berestovskyy force-pushed the andriy/exc-1735-shedule-inner-round branch from f0ea8a7 to d4cd725 Compare September 30, 2024 20:24
@berestovskyy berestovskyy changed the title feat: EXC-1735: Move scheduling strategy into the inner round feat: EXC-1735: Move scheduling into the inner round Sep 30, 2024
@berestovskyy berestovskyy marked this pull request as ready for review October 1, 2024 07:08
@berestovskyy berestovskyy requested a review from a team as a code owner October 1, 2024 07:08
@@ -626,9 +626,9 @@ impl SchedulerImpl {
#[allow(clippy::too_many_arguments, clippy::type_complexity)]
fn inner_round<'a>(
&'a self,
round_log: &ReplicaLogger,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personal preference: My approach to argument ordering (and something that, accidentally or not, I see reflected in a lot of places) is:

  • at a high level, start with input arguments; then output arguments; and finally incidental stuff, such as logs and metrics;
  • within each of these groups (or more likely within the first) go by importance (e.g. first the state you are modifying, then the round, etc.; in this case, beyond the state it's all a bit subjective).

IOW, I would add the log at the very end (or at the very end, before the metrics).

self.rate_limiting_of_heap_delta,
let mut canisters = state.take_canister_states();

// Scheduling.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

High-level comment: Does this change help move us closer to the quick fix? (I.e. does it make it easier to charge all canisters that got a chance at a full round or not?)

Because OTOH, we have both subnets that spend 15-20 ms scheduling; and subnets that do 12 inner loop iterations per round. Luckily no subnet happens to be in both those groups, but even assuming no increase in these numbers, there's nothing stopping a subnet from doing 250 ms worth of scheduling out of a 400 ms round.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change shifts the schedule by four canisters per inner round, i.e. potentially 12 times faster. I'm aware of the potential performance impact but have prioritized other optimizations for the upcoming release...


let metrics = &system_state.canister_metrics;
// The inner round was skipped once before breaking the round.
assert_eq!(metrics.skipped_round_due_to_no_messages, 1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Low priority: Could we avoid unnecessarily bumping this counter on every round when we execute all messages?

Or rename it to something like "rounds when we executed all messages"? (Although this can probably be inferred from the number of instructions executed in that round.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, we'll have performance optimizations in https://dfinity.atlassian.net/browse/EXC-1617 It's an orthogonal change to this MR.

@berestovskyy berestovskyy marked this pull request as draft October 2, 2024 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants